<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <a v-show="!isLogin" href="#" @click="login()">登录</a>
    <a v-show="isLogin" href="#" @click="logout()">退出</a>
    <span v-show="isLogin" >
        <input type="text" v-model="name">
        <input type="button" value="添加"  @click="addfn()">
    </span>

    <hr>
    <ul>
        <li v-for="name in arr">{{name}}</li>
    </ul>
</div>

<script src="vue.js"></script>
<script>
    let v=new Vue({
        el:"div",
        data:{
            isLogin:false,
            arr:["艾斯","萨博","路飞"],
            name:""
        },
        methods:{
            login:function () {
                v.isLogin=true;
            },
            logout:function () {
                if (confirm("确定退出?")){
                    v.isLogin=false;
                }
            },
            addfn:function () {
                v.arr.push(v.name)
            }
        }
    })
</script>
</body>
</html>